from connect.conn_mysql import Connect   

class Person_Center(Connect):

    def last_message(self):
        detail_sql = 'select * from message order by id desc limit 1;'
        result = self.select_one(detail_sql)
        if result:return{
                        'status':1,
                        'errorCode':66,
                        'errorMsg':'请求成功',
                        'resultBody':f'你这乘车的详情是{result}'
                    }
        if result==None:return{
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'赶快去体验拼车的乐趣吧'}
    
    def all_message(self,user_id):
        all_sql = 'select * from message where user_id = %s'
        result = self.select_all(all_sql,(user_id,))
        if user_id == None:return{
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'请输入你的user_id'
                        }
        if result:return{
                        'status':1,
                        'errorCode':66,
                        'errorMsg':'请求成功',
                        'resultBody':f'你user_id乘车的详情是{result}'
                    }
